Skip to content

[feature](routineload) Add routine load target-table alter support#64878

Open
0AyanamiRei wants to merge 23 commits into
apache:masterfrom
0AyanamiRei:feature/routine-load-target-table-switch
Open

[feature](routineload) Add routine load target-table alter support#64878
0AyanamiRei wants to merge 23 commits into
apache:masterfrom
0AyanamiRei:feature/routine-load-target-table-switch

Conversation

@0AyanamiRei

@0AyanamiRei 0AyanamiRei commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: N/A

Related PR: N/A

Problem Summary:

Routine Load target-table alteration was initially limited to the target-only syntax ALTER ROUTINE LOAD FOR [db.]job ON table. It could not alter supported job or Kafka data-source properties in the same statement.

This PR replaces that syntax with the explicit, composable form:

ALTER ROUTINE LOAD FOR [<db>.]<job_name>
SET TARGET TABLE = "<table_name>"
[<job_properties>]
FROM KAFKA
[<data_source_properties>]

The implementation has the following behavior and constraints:

  • SET TARGET TABLE is supported only for Kafka Routine Load jobs. Kinesis jobs reject target-table changes, while their existing property-only ALTER behavior remains unchanged.
  • The target switch can be combined with supported job properties and Kafka data-source properties.
  • Target switching remains mutually exclusive with load clauses such as COLUMNS, WHERE, and PARTITION.
  • The job must be paused and single-table.
  • The target must be a non-temporary OLAP table in the job database, pass LOAD privilege checks, and be compatible with the existing load definition and distribution mode.
  • Existing Doris mutable-property allowlists and Kafka progress behavior are preserved.

Release note

ALTER ROUTINE LOAD now uses SET TARGET TABLE = "table" to switch the target table for Kafka Routine Load jobs and supports combining the switch with supported job and Kafka data-source properties.

Check List (For Author)

  • Test
    • Regression test
    • Unit Test
    • Manual test
    • No need to test or manual test
  • Behavior changed:
    • No.
    • Yes. Kafka Routine Load jobs use SET TARGET TABLE = "table" for target-table switching. Kinesis target-table switching is not supported.
  • Does this need documentation?

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

### What problem does this PR solve?

Issue Number: None
Related PR: None
Problem Summary: Allow paused single-table Routine Load jobs to switch their target table with ALTER ROUTINE LOAD FOR [db.]job ON <table>, while preserving existing progress and replaying the new table binding from edit log.

### Release note

Support ALTER ROUTINE LOAD ... ON <table> to switch the target table for paused single-table routine load jobs.

### Check List (For Author)

- Test: FE unit test
  - "/data/data3/huangruixin/include/src-master/apache-maven-3.9.9/bin/mvn -pl fe-core -am -DskipITs -Dcheckstyle.skip=true -DfailIfNoTests=false -Dtest=org.apache.doris.nereids.trees.plans.commands.AlterRoutineLoadCommandTest,org.apache.doris.persist.AlterRoutineLoadOperationLogTest,org.apache.doris.load.routineload.KafkaRoutineLoadJobTest test"
  - Kinesis unit tests skipped per user request
- Behavior changed: Yes (new ALTER ROUTINE LOAD target-table switch behavior)
- Does this need documentation: Yes (documented in /data/data3/huangruixin/docs/routine-load-alter-table-design.html)
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@0AyanamiRei
0AyanamiRei marked this pull request as draft June 26, 2026 06:04
### What problem does this PR solve?

Issue Number: None

Related PR: apache#64878

Problem Summary: Follow-up review found two issues in the new routine load target-table alter support. First, `AlterRoutineLoadCommand` had an import order regression that could fail FE checkstyle. Second, alter validation only rechecked `PARTIAL_COLUMNS=true` from the current command, which left the effective partial-update state under-validated when the existing job or a `unique_key_update_mode` change required merge-on-write semantics. This change restores import ordering, validates the effective unique key update mode against the destination table, and adds focused FE unit coverage for those cases.

### Release note

Routine Load alter now rejects target-table or unique-key-update changes that are incompatible with partial update requirements.

### Check List (For Author)

- Test: Unit Test
- Behavior changed: Yes
- Does this need documentation: No
@0AyanamiRei
0AyanamiRei marked this pull request as ready for review June 29, 2026 01:11
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

### What problem does this PR solve?

Issue Number: None

Related PR: apache#64878

Problem Summary: The routine load target-table alter change hit FE checkstyle in CI because one validation error message exceeded the line-length limit and a unit-test import order did not match the FE custom import ordering rule. This commit makes the minimal formatting-only fixes so the branch aligns with FE style checks.

### Release note

None

### Check List (For Author)

- Test: No need to test (formatting-only fix requested by reviewer; no local build or test run)
- Behavior changed: No
- Does this need documentation: No
@0AyanamiRei 0AyanamiRei changed the title [feature](fe) Add routine load target-table alter support [feature](routineload) Add routine load target-table alter support Jun 29, 2026
@sollhui

sollhui commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

/review

### What problem does this PR solve?

Issue Number: None

Related PR: apache#64878

Problem Summary: The routine load target-table alter implementation had a single-use helper for constructing the validation load descriptor snapshot, and the parser branch for table-only alter did not mark the intended phase-one scope. This commit inlines the one-off snapshot construction at the validation call site and documents that the current parser branch only supports target table alteration before future support for combining target-table and property changes.

### Release note

None

### Check List (For Author)

- Test: No need to test (review follow-up only; no local build or test run)
- Behavior changed: No
- Does this need documentation: No
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed for PR 64878 at head 760890d.

I found one correctness issue: validation can accept an alter that later leaves the routine-load job in partial-update mode on a non-MoW table.

Critical checkpoints:

  • Goal: the PR adds single-table routine-load target-table alteration while preserving stream progress; the implementation largely wires parser, command validation, job mutation, replay, display, and tests, but the partial-update validation path is inconsistent with mutation for one property combination.
  • Scope/focus: the target-table change is small and localized to routine-load command/job/persistence paths.
  • Concurrency/lifecycle: mutation is still gated by the existing paused-job write lock; no new background thread or lock order was introduced.
  • Configuration/session propagation: no new config item; existing routine-load session/job properties are reused.
  • Compatibility/persistence: new log field is backward-readable by current code; target-table id is replayed in Kafka and Kinesis paths.
  • Parallel paths: Kafka and Kinesis both update/replay targetTableId; scheduling/task planning uses the current job tableId.
  • Tests: parser/command/persistence/unit coverage and a Kafka regression were added. I verified git diff --check and mvn -pl fe-core -DskipTests checkstyle:check. I did not run FE compile/unit/regression tests because this checkout lacks thirdparty/installed/bin/protoc and thirdparty/installed.
  • User focus: no additional user-provided focus was present.

Subagent conclusions: optimizer-rewrite proposed OPT-001, which became inline comment MAIN-001. tests-session-config reported no distinct candidate. Convergence round 1 ended with both live subagents replying NO_NEW_VALUABLE_FINDINGS for the same current ledger/comment set.

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: Codex completed, but no new pull request review was submitted for the current head SHA.
Workflow run: https://github.com/apache/doris/actions/runs/28345324644

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 50.63% (40/79) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29129 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 760890d5d7eef15765b1fc92f16783d7301870c2, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17723	4017	4145	4017
q2	2022	319	187	187
q3	10328	1532	851	851
q4	4699	468	341	341
q5	7700	845	582	582
q6	204	173	141	141
q7	776	848	628	628
q8	10199	1487	1606	1487
q9	5907	4480	4460	4460
q10	6772	1809	1503	1503
q11	440	286	248	248
q12	629	430	310	310
q13	18087	3385	2817	2817
q14	265	256	244	244
q15	q16	782	773	706	706
q17	1029	955	1029	955
q18	6797	5786	5453	5453
q19	1173	1277	1096	1096
q20	509	411	263	263
q21	5699	2559	2539	2539
q22	446	356	301	301
Total cold run time: 102186 ms
Total hot run time: 29129 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4418	4256	4290	4256
q2	320	366	227	227
q3	4539	4941	4364	4364
q4	2083	2151	1366	1366
q5	4451	4327	4297	4297
q6	233	181	134	134
q7	1740	1936	1826	1826
q8	2423	2181	2100	2100
q9	8114	8044	8082	8044
q10	4852	4758	4301	4301
q11	565	425	389	389
q12	735	762	646	646
q13	3317	3589	2994	2994
q14	300	305	278	278
q15	q16	758	761	679	679
q17	1350	1344	1328	1328
q18	7947	7410	6831	6831
q19	1137	1104	1129	1104
q20	2274	2215	1948	1948
q21	5268	4573	4537	4537
q22	511	465	402	402
Total cold run time: 57335 ms
Total hot run time: 52051 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 171607 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 760890d5d7eef15765b1fc92f16783d7301870c2, data reload: false

query5	4322	626	484	484
query6	430	183	171	171
query7	4810	553	302	302
query8	334	180	163	163
query9	8757	4085	4079	4079
query10	424	316	261	261
query11	5806	2352	2123	2123
query12	156	102	99	99
query13	1278	579	413	413
query14	6270	5269	4957	4957
query14_1	4327	4295	4289	4289
query15	219	202	179	179
query16	1038	447	432	432
query17	1107	711	604	604
query18	2432	465	337	337
query19	197	181	145	145
query20	113	108	103	103
query21	214	144	116	116
query22	13798	13672	13407	13407
query23	17262	16399	16148	16148
query23_1	16279	16175	16292	16175
query24	7465	1786	1326	1326
query24_1	1337	1283	1325	1283
query25	579	455	388	388
query26	1318	326	174	174
query27	2678	583	345	345
query28	4474	2032	2037	2032
query29	1099	651	520	520
query30	309	235	208	208
query31	1126	1091	946	946
query32	106	64	60	60
query33	547	320	262	262
query34	1167	1109	654	654
query35	775	796	686	686
query36	1414	1390	1241	1241
query37	154	115	92	92
query38	1902	1723	1671	1671
query39	926	936	915	915
query39_1	873	882	896	882
query40	231	126	106	106
query41	69	68	68	68
query42	91	90	88	88
query43	324	322	277	277
query44	1473	817	782	782
query45	216	194	181	181
query46	1075	1199	760	760
query47	2345	2351	2264	2264
query48	404	411	323	323
query49	595	438	326	326
query50	1069	370	267	267
query51	4406	4417	4350	4350
query52	82	83	73	73
query53	244	274	199	199
query54	277	234	211	211
query55	77	73	68	68
query56	261	233	236	233
query57	1428	1435	1302	1302
query58	245	217	223	217
query59	1558	1650	1439	1439
query60	284	256	239	239
query61	182	177	213	177
query62	704	644	573	573
query63	237	193	190	190
query64	2525	773	625	625
query65	4820	4804	4771	4771
query66	1818	460	330	330
query67	28846	28759	28682	28682
query68	3220	1539	931	931
query69	418	308	261	261
query70	1082	1022	991	991
query71	311	238	213	213
query72	2915	2867	2340	2340
query73	890	800	439	439
query74	5133	4990	4751	4751
query75	2601	2541	2180	2180
query76	2308	1201	783	783
query77	392	379	293	293
query78	12392	12431	11997	11997
query79	1407	1137	762	762
query80	1236	454	387	387
query81	514	280	250	250
query82	612	156	117	117
query83	317	276	247	247
query84	264	139	115	115
query85	885	510	438	438
query86	439	325	276	276
query87	1841	1827	1776	1776
query88	3756	2810	2779	2779
query89	426	378	334	334
query90	1870	186	187	186
query91	174	160	137	137
query92	65	62	53	53
query93	1600	1474	874	874
query94	715	352	333	333
query95	669	469	347	347
query96	1139	806	348	348
query97	2683	2660	2554	2554
query98	217	206	201	201
query99	1161	1163	1067	1067
Total cold run time: 257841 ms
Total hot run time: 171607 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.95 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 760890d5d7eef15765b1fc92f16783d7301870c2, data reload: false

query1	0.01	0.01	0.00
query2	0.10	0.04	0.05
query3	0.25	0.16	0.13
query4	1.60	0.14	0.14
query5	0.24	0.22	0.22
query6	1.26	1.05	1.02
query7	0.03	0.01	0.01
query8	0.06	0.04	0.04
query9	0.39	0.32	0.34
query10	0.58	0.54	0.58
query11	0.18	0.15	0.15
query12	0.18	0.15	0.14
query13	0.48	0.47	0.47
query14	1.02	1.01	0.98
query15	0.61	0.59	0.58
query16	0.33	0.31	0.30
query17	1.08	1.12	1.04
query18	0.22	0.21	0.22
query19	2.05	1.90	1.90
query20	0.01	0.01	0.01
query21	15.44	0.19	0.14
query22	4.95	0.06	0.05
query23	16.13	0.31	0.12
query24	2.98	0.41	0.31
query25	0.11	0.06	0.04
query26	0.74	0.23	0.15
query27	0.05	0.03	0.03
query28	3.53	0.90	0.52
query29	12.50	4.33	3.45
query30	0.28	0.15	0.16
query31	2.77	0.60	0.31
query32	3.22	0.60	0.50
query33	3.17	3.16	3.31
query34	15.51	4.21	3.50
query35	3.48	3.51	3.54
query36	0.54	0.42	0.43
query37	0.10	0.07	0.06
query38	0.05	0.04	0.03
query39	0.04	0.03	0.03
query40	0.17	0.16	0.15
query41	0.08	0.03	0.03
query42	0.03	0.02	0.02
query43	0.04	0.04	0.03
Total cold run time: 96.59 s
Total hot run time: 24.95 s

### What problem does this PR solve?

Issue Number: None

Related PR: apache#64878

Problem Summary: ALTER ROUTINE LOAD validation handled unique_key_update_mode and legacy partial_columns with different precedence from the mutation path. An ALTER containing unique_key_update_mode=UPSERT and partial_columns=true could pass validation on a non-MoW table, then be applied as UPDATE_FIXED_COLUMNS. Flexible partial-update ALTERs on non-MoW tables were also rejected by the generic PARTIAL_COLUMNS validation before reaching the flexible partial-update validation path. This change makes generic partial-column validation apply only to fixed partial update mode and makes the mutation path ignore legacy partial_columns when an explicit unique_key_update_mode is present. The routine load alter regression test also declares its polling counters as local variables to satisfy regression framework script checks.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - ./run-fe-ut.sh --run org.apache.doris.nereids.trees.plans.commands.AlterRoutineLoadCommandTest,org.apache.doris.load.routineload.KafkaRoutineLoadJobTest,org.apache.doris.load.routineload.KinesisRoutineLoadJobTest
- Behavior changed: No
- Does this need documentation: No
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29187 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit a756d7c8ca4379f1e75c58840d7627a5e165525d, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17696	4113	4050	4050
q2	2013	325	195	195
q3	10284	1378	842	842
q4	4672	477	340	340
q5	7552	831	551	551
q6	194	172	140	140
q7	746	806	617	617
q8	9683	1373	1399	1373
q9	5907	4337	4304	4304
q10	6810	1735	1448	1448
q11	509	352	334	334
q12	765	608	472	472
q13	18157	3315	2686	2686
q14	267	260	246	246
q15	q16	781	778	710	710
q17	993	1046	990	990
q18	6974	5891	5524	5524
q19	1371	1264	1090	1090
q20	751	660	590	590
q21	5708	2578	2381	2381
q22	425	356	304	304
Total cold run time: 102258 ms
Total hot run time: 29187 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4492	4402	4497	4402
q2	287	313	209	209
q3	4583	4957	4468	4468
q4	2045	2222	1368	1368
q5	4404	4248	4290	4248
q6	239	178	132	132
q7	1708	1955	1704	1704
q8	2493	2242	2109	2109
q9	7863	7728	7730	7728
q10	4676	4654	4175	4175
q11	586	415	386	386
q12	749	754	541	541
q13	3403	3713	3015	3015
q14	308	315	274	274
q15	q16	715	734	642	642
q17	1365	1331	1339	1331
q18	8034	7464	6802	6802
q19	1152	1084	1108	1084
q20	2226	2224	1919	1919
q21	5261	4606	4466	4466
q22	540	492	399	399
Total cold run time: 57129 ms
Total hot run time: 51402 ms

@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29668 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit a756d7c8ca4379f1e75c58840d7627a5e165525d, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17577	4085	4086	4085
q2	2038	356	203	203
q3	10245	1416	823	823
q4	4732	474	337	337
q5	7942	877	572	572
q6	273	172	136	136
q7	800	815	617	617
q8	10712	1667	1594	1594
q9	5925	4377	4393	4377
q10	6848	1756	1464	1464
q11	525	347	319	319
q12	728	586	455	455
q13	18092	3398	2763	2763
q14	259	259	241	241
q15	q16	787	784	723	723
q17	1044	1041	985	985
q18	7149	5816	5670	5670
q19	1168	1308	1063	1063
q20	808	692	606	606
q21	5814	2674	2340	2340
q22	427	364	295	295
Total cold run time: 103893 ms
Total hot run time: 29668 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4399	4304	4315	4304
q2	302	320	213	213
q3	4621	5025	4459	4459
q4	2075	2180	1357	1357
q5	4403	4286	4289	4286
q6	258	173	125	125
q7	1741	1635	1443	1443
q8	2279	1988	1932	1932
q9	7191	7448	7155	7155
q10	4711	4594	4163	4163
q11	538	400	359	359
q12	760	751	540	540
q13	2998	3376	2813	2813
q14	302	295	270	270
q15	q16	680	706	617	617
q17	1296	1260	1266	1260
q18	7283	7023	6963	6963
q19	1125	1098	1115	1098
q20	2239	2210	1953	1953
q21	5268	4566	4368	4368
q22	540	464	410	410
Total cold run time: 55009 ms
Total hot run time: 50088 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 177835 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit a756d7c8ca4379f1e75c58840d7627a5e165525d, data reload: false

query5	4380	632	516	516
query6	473	247	242	242
query7	3593	582	354	354
query8	220	194	177	177
query9	4538	4087	4049	4049
query10	394	349	301	301
query11	2591	2357	2127	2127
query12	151	107	104	104
query13	607	555	422	422
query14	5605	5193	4920	4920
query14_1	4276	4213	4281	4213
query15	206	208	179	179
query16	654	476	451	451
query17	698	718	572	572
query18	463	472	352	352
query19	205	191	153	153
query20	110	108	107	107
query21	172	162	142	142
query22	13529	13542	13402	13402
query23	17412	16566	16079	16079
query23_1	16231	16259	16224	16224
query24	9339	1754	1294	1294
query24_1	1271	1299	1285	1285
query25	578	462	380	380
query26	1362	345	207	207
query27	2636	597	375	375
query28	4373	2000	1980	1980
query29	1048	648	488	488
query30	442	275	235	235
query31	1136	1090	973	973
query32	111	62	64	62
query33	789	324	265	265
query34	1458	1144	632	632
query35	854	779	663	663
query36	1202	1185	1076	1076
query37	156	109	96	96
query38	1883	1710	1622	1622
query39	901	888	874	874
query39_1	831	865	873	865
query40	244	165	140	140
query41	63	64	62	62
query42	91	91	93	91
query43	315	333	290	290
query44	1441	782	758	758
query45	195	181	175	175
query46	1095	1211	699	699
query47	2129	2110	1985	1985
query48	399	412	306	306
query49	583	457	303	303
query50	1081	425	332	332
query51	10894	10393	10315	10315
query52	85	84	72	72
query53	254	279	198	198
query54	411	242	223	223
query55	166	74	66	66
query56	298	299	283	283
query57	1313	1294	1170	1170
query58	320	269	255	255
query59	1665	1673	1473	1473
query60	318	278	261	261
query61	149	148	153	148
query62	541	493	431	431
query63	241	202	199	199
query64	3332	1043	885	885
query65	4716	4624	4627	4624
query66	2286	563	381	381
query67	29320	29393	29256	29256
query68	3159	1623	1004	1004
query69	411	295	273	273
query70	1043	962	1000	962
query71	368	346	326	326
query72	3475	2672	2450	2450
query73	803	810	409	409
query74	5077	4983	4747	4747
query75	2532	2508	2137	2137
query76	3011	1187	781	781
query77	353	383	288	288
query78	11967	11946	11399	11399
query79	1334	1108	767	767
query80	686	560	462	462
query81	462	349	290	290
query82	550	158	122	122
query83	407	319	302	302
query84	326	161	129	129
query85	953	622	524	524
query86	354	286	278	278
query87	1825	1818	1745	1745
query88	3686	2774	2757	2757
query89	429	376	322	322
query90	1778	185	194	185
query91	202	189	160	160
query92	73	61	59	59
query93	1675	1517	1016	1016
query94	567	342	310	310
query95	794	580	488	488
query96	1047	810	362	362
query97	2616	2633	2469	2469
query98	218	205	197	197
query99	1104	1126	1005	1005
Total cold run time: 246687 ms
Total hot run time: 177835 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 25.06 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit a756d7c8ca4379f1e75c58840d7627a5e165525d, data reload: false

query1	0.01	0.00	0.00
query2	0.10	0.05	0.06
query3	0.29	0.14	0.14
query4	1.61	0.14	0.15
query5	0.25	0.22	0.21
query6	1.24	1.10	1.05
query7	0.05	0.01	0.01
query8	0.07	0.04	0.04
query9	0.37	0.31	0.31
query10	0.60	0.54	0.54
query11	0.19	0.14	0.14
query12	0.18	0.14	0.14
query13	0.46	0.48	0.47
query14	1.01	1.00	1.01
query15	0.62	0.59	0.59
query16	0.31	0.31	0.32
query17	1.09	1.12	1.11
query18	0.22	0.20	0.20
query19	1.98	1.91	1.95
query20	0.02	0.02	0.01
query21	15.43	0.22	0.13
query22	4.83	0.06	0.05
query23	16.14	0.30	0.12
query24	2.88	0.43	0.32
query25	0.10	0.06	0.04
query26	0.73	0.20	0.15
query27	0.03	0.03	0.05
query28	3.50	0.91	0.55
query29	12.47	4.08	3.29
query30	0.28	0.15	0.15
query31	2.79	0.59	0.31
query32	3.22	0.59	0.48
query33	3.14	3.28	3.19
query34	15.51	4.24	3.53
query35	3.55	3.53	3.53
query36	0.56	0.45	0.43
query37	0.09	0.06	0.07
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.18	0.16	0.16
query41	0.09	0.03	0.03
query42	0.05	0.03	0.03
query43	0.04	0.04	0.04
Total cold run time: 96.37 s
Total hot run time: 25.06 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 67.65% (46/68) 🎉
Increment coverage report
Complete coverage report

@sollhui

sollhui commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for four distinct correctness issues on the current head: the explicit FROM source type is discarded, target compatibility is checked against the old rather than effective job properties, and rejected combined ALTERs can leave unjournaled live mutations in both Kafka and Kinesis jobs.

Checkpoint conclusions:

  • Goal and scope: the target-table switch is otherwise focused and the target-only Kafka/Kinesis plumbing, progress preservation, legacy-log zero default, and replay assignment are present. The four issues below prevent the advertised combined transition from being safe.
  • Concurrency, lifecycle, and atomicity: paused-job locking and task clearing were traced through resume and transaction callbacks. Existing threads already cover mutable-target races; the two new source-specific findings below are distinct non-concurrent validation-to-commit failures.
  • Validation and compatibility: TARGET remains non-reserved, ordinary string decoding is preserved, and target OLAP/non-temporary/single-table checks are present. However, the parsed source type is not preserved and same-statement effective update properties are omitted from target planning.
  • Parallel paths and persistence: Kafka and Kinesis both assign and replay the new target ID, but both also mutate live source state before a throwable membership check and before the target/EditLog commit point, so a failed command diverges from durable state. Existing replay, image, Cloud, and journal-lock concerns were deduplicated against live threads.
  • Tests and results: the changed tests cover matching parser forms, happy-path target switches, progress preservation, and legacy-log reading, but not these four negative cases. No local build or tests were run, as required by the review task. Live FE UT, compile, formatter, license, P0/nonconcurrent/external regression, performance, and vault P0 checks pass; cloud_p0 and check_coverage_fe are red, and their TeamCity details require authentication.
  • Performance and observability: target validation adds planning only on explicit ALTER, not a scheduling hot path, and existing ALTER errors, job logs, SHOW state, and journal metrics remain available. No additional issue was found here.
  • User focus: no extra focus points were supplied.

All three independent reviewers reread this exact four-comment set and returned NO_NEW_VALUABLE_FINDINGS on round 2. The live head and inline-thread set were refreshed immediately before submission, and no unresolved or duplicate candidate remains.

### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#64878

Problem Summary: FE incremental coverage did not execute the real RoutineLoadJob target-table validation path and missed compatibility branches when ALTER contains no target table. The P0 scenario also combined target switching with unrelated property changes. Add focused unit tests for planner success and failure, lock release, the single-table invariant, legacy ALTER behavior, and Kafka/Kinesis no-target compatibility. Narrow the regression scenario to a target-only switch and an incompatible-target rejection.

### Release note

None

### Check List (For Author)

- Test: Unit Test and Regression test
    - ./run-fe-ut.sh --coverage --run relevant Routine Load test classes: 57 passed
    - ./build.sh --fe -j48: passed
    - Regression case added but not run locally because this worktree has no isolated BE/Kafka environment
- Behavior changed: No
- Does this need documentation: No
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@sollhui

sollhui commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes: five distinct P1 correctness issues remain in the newly advertised combined target/source transition. Existing live threads already cover stale-target races, effective-definition validation, failed-ALTER atomicity, explicit source-type handling, and checkpoint/replay issues, so I did not duplicate them.

Critical checkpoint conclusions:

  • Goal and scope: all 15 changed files were reviewed. The parser and target-only happy path work, but the combined transition is not yet safe across the Kafka/Kinesis parallel paths.
  • Concurrency and lifecycle: paused-state and job-lock fencing were traced through scheduling and transaction callbacks. Existing target races are already covered; source identity/progress publication and replay still fail in the five cases below.
  • Security and RBAC: current-job authorization precedes target privilege checking, and target LOAD authorization precedes metadata lookup. Existing discussions cover the remaining mutable-target authorization/state races.
  • Persistence and compatibility: old operation logs safely default the new target ID to zero and both replay consumers are wired, but follower/image equivalence remains broken for Kinesis in the case below (in addition to already reported Kafka/checkpoint issues).
  • Data correctness and parallel paths: Kafka and Kinesis can carry stale or synthetic offsets, shards, and caches across a newly committed target/source identity. The five inline comments identify distinct reachable cases.
  • Tests and results: the added tests cover syntax, target-only success/failure, basic persistence, old-log defaulting, and ordered Kafka output, but not these source-identity, membership, default-preservation, or failover cases. This was a static review only; builds and tests were not run under the review contract.
  • Configuration, protocol, performance, and observability: no new configuration, FE-BE protocol, hot-path, memory, or observability blocker was found. Any remote source validation should remain outside job locks and use a generation recheck before publication.
  • User focus: none was supplied, so the complete PR was reviewed.


modifyPropertiesInternal(jobProperties, dataSourceProperties);
if (command.hasTargetTable()) {
this.tableId = command.getTargetTableId();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Reset Kinesis state when the region changes. The source mutation below sets resetProgress only for a new stream name; an ALTER that keeps the same name but changes aws.region commits this new target and region while retaining progress, custom/open/closed shard IDs, and lag from the old physical stream. Pinned jobs then skip ListShards completely, and dynamic jobs can reuse an old sequence number when the new region exposes the same standard shard ID, producing an invalid starting position or repeated failures. Treat a region change as a source-identity change just like a stream change (or require validated explicit positions), and cover both pinned and dynamic jobs.


AlterRoutineLoadJobOperationLog log = new AlterRoutineLoadJobOperationLog(this.id,
jobProperties, dataSourceProperties);
jobProperties, dataSourceProperties, command.getTargetTableId());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Validate explicit shards against the staged stream before journaling this transition. When kinesis_stream is supplied, modifyPropertiesInternal() clears progress, copies the requested IDs into customKinesisShards, and skips checkShards() because resetProgress is true. On resume that nonempty custom list also makes refreshKafkaPartitions() skip ListShards, so SET TARGET TABLE ... FROM KINESIS("kinesis_stream"="stream-b","kinesis_shards"="missing","kinesis_shards_pos"="LATEST") succeeds and persists a definition that will schedule a nonexistent shard. Resolve the effective endpoint/region/stream and fetch its actual shards outside the job lock, then recheck the job-definition generation and reject missing IDs before publishing the target/source delta.


modifyPropertiesInternal(jobProperties, dataSourceProperties);
if (command.hasTargetTable()) {
tableId = command.getTargetTableId();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Re-seed progress when a broker-list change selects a different Kafka cluster. With the topic unchanged, modifyPropertiesInternal() only replaces brokerList; it retains progress, custom/current partitions, and the latest-offset cache. Pinned jobs then skip metadata discovery, and a dynamic job whose new cluster has the same numeric partition IDs appears unchanged, so tasks combine the new brokers and target here with offsets from the old cluster. Switching cluster A at offset 1000 to cluster B can therefore skip B's first 1000 records or pause with OFFSET_OUT_OF_RANGE. Resolve the cluster ID and any requested offsets against the effective new brokers outside the job lock; if the cluster changed, require those validated offsets or reset/reseed all progress and partition caches, persist that prepared decision for replay, and recheck the job generation before committing.

Deencapsulation.setField(routineLoadJob, "progress", progress);

Map<String, String> sourceProperties = Maps.newHashMap();
sourceProperties.put("property.client.id", "target-switch");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Preserve the existing Kafka default in this custom-only combined ALTER. Although this statement supplies only client.id, KafkaDataSourceProperties.analyze() falls through to analyzeKafkaDefaultOffsetProperty(), which synthesizes kafka_default_offsets=OFFSET_END; modifyPropertiesInternal() then merges that value into the live job before assigning and journaling the new target. A job created with OFFSET_BEGINNING can therefore execute the advertised SET TARGET TABLE ... FROM KAFKA("property.client.id"=...) form and silently make every later-discovered partition start at the end, skipping its backlog. This test masks the overwrite because the job starts with the implicit END default and never asserts it. Keep the default absent from an ALTER delta unless it was explicitly supplied (or needed for explicit partitions), and cover live/replay/image preservation from OFFSET_BEGINNING.

modifyPropertiesInternal(log.getJobProperties(),
(KinesisDataSourceProperties) log.getDataSourceProperties());
if (log.getTargetTableId() != 0) {
this.tableId = log.getTargetTableId();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Do not make Kinesis replay depend on follower-local shard discovery. Dynamic discovery adds shards to the leader's progress without journaling that discovery, so the leader can discover shard-0, pause before any task commit, and successfully journal an explicit shard position plus this target. A follower or older image with empty progress then replays the same record, checkShards() throws, this catch consumes the journal entry, and the tableId assignment here is skipped. The new replay test cannot exercise this because its captured record has no explicit shard positions (and it also pre-seeds shard-0). Replay a fully prepared leader-validated transition without consulting local progress (or persist the required canonical state in the same record), and add the empty-progress failover/image case.

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 94.12% (64/68) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 30292 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 0fca4e77f1dbddb1a549d0ee791fd5c47dff4d98, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17604	4245	4225	4225
q2	2010	329	223	223
q3	10261	1447	877	877
q4	4681	478	337	337
q5	7526	895	590	590
q6	178	174	141	141
q7	768	838	625	625
q8	9407	1672	1758	1672
q9	5587	4405	4401	4401
q10	6745	1798	1504	1504
q11	509	362	323	323
q12	748	583	452	452
q13	18085	3407	2737	2737
q14	273	256	243	243
q15	q16	792	784	725	725
q17	998	1053	990	990
q18	6874	5807	5706	5706
q19	1174	1219	1106	1106
q20	802	709	616	616
q21	5569	2675	2500	2500
q22	428	363	299	299
Total cold run time: 101019 ms
Total hot run time: 30292 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4493	4463	4451	4451
q2	292	324	213	213
q3	4654	5013	4474	4474
q4	2081	2189	1356	1356
q5	4443	4303	4300	4300
q6	227	178	129	129
q7	1732	2209	1729	1729
q8	2638	2195	2295	2195
q9	8030	7959	7817	7817
q10	4756	4652	4243	4243
q11	581	434	378	378
q12	830	780	548	548
q13	3313	3600	3001	3001
q14	308	304	275	275
q15	q16	717	723	632	632
q17	1410	1347	1396	1347
q18	8155	7559	7227	7227
q19	1174	1173	1105	1105
q20	2214	2233	1925	1925
q21	5250	4560	4416	4416
q22	504	461	397	397
Total cold run time: 57802 ms
Total hot run time: 52158 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 177484 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 0fca4e77f1dbddb1a549d0ee791fd5c47dff4d98, data reload: false

query5	4328	611	499	499
query6	461	221	204	204
query7	4848	555	336	336
query8	352	186	179	179
query9	8760	4031	4034	4031
query10	477	370	310	310
query11	5965	2317	2140	2140
query12	162	105	102	102
query13	1266	598	429	429
query14	6258	5214	4890	4890
query14_1	4244	4234	4223	4223
query15	218	209	181	181
query16	1045	472	477	472
query17	993	699	559	559
query18	2448	462	346	346
query19	202	180	147	147
query20	114	107	106	106
query21	234	156	130	130
query22	13453	13550	13425	13425
query23	17452	16550	16198	16198
query23_1	16314	16346	16281	16281
query24	7562	1748	1269	1269
query24_1	1301	1300	1280	1280
query25	548	433	356	356
query26	1358	365	211	211
query27	2580	644	388	388
query28	4521	2006	1941	1941
query29	1086	591	478	478
query30	345	261	224	224
query31	1102	1084	988	988
query32	101	62	59	59
query33	541	315	255	255
query34	1197	1127	651	651
query35	763	790	665	665
query36	1189	1203	1024	1024
query37	155	107	90	90
query38	1875	1718	1621	1621
query39	882	871	841	841
query39_1	876	842	873	842
query40	249	171	150	150
query41	73	69	70	69
query42	96	98	91	91
query43	322	328	278	278
query44	1433	808	770	770
query45	210	181	180	180
query46	1113	1178	765	765
query47	2095	2165	2029	2029
query48	415	402	293	293
query49	597	434	342	342
query50	1063	437	353	353
query51	10827	10671	10657	10657
query52	89	90	75	75
query53	280	283	209	209
query54	303	261	228	228
query55	83	71	68	68
query56	318	314	306	306
query57	1324	1312	1212	1212
query58	325	281	263	263
query59	1597	1669	1461	1461
query60	319	293	257	257
query61	181	175	181	175
query62	552	509	433	433
query63	243	210	211	210
query64	2917	1136	842	842
query65	4703	4673	4631	4631
query66	1846	518	375	375
query67	29350	29317	28567	28567
query68	3289	1572	962	962
query69	419	301	257	257
query70	1045	989	945	945
query71	382	348	310	310
query72	3077	2705	2390	2390
query73	831	740	448	448
query74	5103	4928	4728	4728
query75	2514	2507	2133	2133
query76	2307	1202	759	759
query77	348	377	277	277
query78	11957	11809	11288	11288
query79	1432	1177	749	749
query80	1353	561	484	484
query81	566	337	294	294
query82	581	154	117	117
query83	392	321	299	299
query84	323	163	133	133
query85	984	611	513	513
query86	427	327	276	276
query87	1824	1824	1761	1761
query88	3724	2799	2754	2754
query89	436	370	329	329
query90	1913	201	190	190
query91	203	188	166	166
query92	59	63	52	52
query93	1565	1573	1082	1082
query94	720	352	325	325
query95	781	543	462	462
query96	1140	817	341	341
query97	2653	2644	2515	2515
query98	215	207	204	204
query99	1109	1124	982	982
Total cold run time: 264240 ms
Total hot run time: 177484 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 25.04 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 0fca4e77f1dbddb1a549d0ee791fd5c47dff4d98, data reload: false

query1	0.00	0.00	0.00
query2	0.12	0.05	0.05
query3	0.25	0.14	0.13
query4	1.62	0.14	0.14
query5	0.25	0.23	0.22
query6	1.23	1.06	1.05
query7	0.04	0.01	0.01
query8	0.06	0.04	0.04
query9	0.38	0.30	0.31
query10	0.53	0.59	0.59
query11	0.19	0.14	0.13
query12	0.19	0.15	0.14
query13	0.46	0.46	0.49
query14	1.02	1.02	1.01
query15	0.63	0.59	0.59
query16	0.34	0.31	0.32
query17	1.06	1.12	1.09
query18	0.23	0.21	0.21
query19	2.10	1.95	1.96
query20	0.02	0.01	0.01
query21	15.46	0.22	0.14
query22	4.79	0.06	0.05
query23	16.10	0.31	0.12
query24	2.95	0.43	0.33
query25	0.11	0.05	0.04
query26	0.73	0.20	0.15
query27	0.04	0.04	0.03
query28	3.56	0.90	0.52
query29	12.47	4.22	3.30
query30	0.28	0.15	0.17
query31	2.79	0.62	0.31
query32	3.23	0.58	0.48
query33	3.16	3.19	3.14
query34	15.70	4.23	3.53
query35	3.50	3.51	3.53
query36	0.55	0.45	0.43
query37	0.09	0.07	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.18	0.17	0.16
query41	0.09	0.03	0.03
query42	0.03	0.03	0.03
query43	0.04	0.03	0.03
Total cold run time: 96.66 s
Total hot run time: 25.04 s

### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#64878

Problem Summary: Merge the latest master into the routine load target-table branch. Resolve the parser conflict by reusing master SqlLiteralUtils for TARGET TABLE string decoding while preserving the target-table ALTER behavior.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - ./run-fe-ut.sh --run org.apache.doris.nereids.trees.plans.commands.AlterRoutineLoadCommandTest
- Behavior changed: No
- Does this need documentation: No
@sollhui

sollhui commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes: two additional P1 correctness issues remain at head 04a5e1085b5b7f03d54a3abdafa9fd9a72ccf182. The new composed target-plus-partial_columns form looks up the database name as the job label, and a successful Cloud target-plus-custom-Kafka ALTER deletes the authoritative durable progress. Existing inline concerns were deduplicated and are not repeated here.

Critical checkpoint conclusions:

  • Goal and proof: The patch adds SET TARGET TABLE, target compatibility planning, Kafka/Kinesis live assignment, EditLog replay, legacy-log decoding, unit tests, and a Kafka target-only P0 case. The happy path is present, but the two inline issues show that advertised job/source composition and progress preservation are not yet correct.
  • Scope and clarity: The 15 changed paths are focused on parser, command validation, Routine Load state, persistence, and tests. Reusing the existing source-property mutators nevertheless crosses planner state, source identity/progress, failover, and image/replay boundaries.
  • Concurrency: The per-job write lock serializes final in-memory apply, but command validation is outside that snapshot and Cloud progress is not atomically coupled to the target/EditLog transition. Existing target/job/descriptor races are already covered by current threads; the new Cloud comment covers the remaining successful-transition failover window.
  • Lifecycle: PAUSE clears active task objects before ALTER, so no distinct simultaneous old/new-target task bug was found. Resume, discovery, default seeding, task creation, transaction progress, failover, replay, and checkpoint reconstruction were traced; existing threads cover the other lifecycle defects.
  • Configuration: No configuration item or dynamic-config behavior is added.
  • Compatibility and persistence: A legacy operation log without targetTableId decodes to the zero sentinel, and current Kafka/Kinesis replay assigns nonzero target IDs. Existing threads already cover state-dependent replay and stale-CREATE checkpoint reconstruction. The second inline comment identifies a separate successful-path deletion of Cloud durable progress.
  • Parallel paths and special conditions: Kafka/Kinesis, target-only/source-only/composed forms, pinned/dynamic partitions or shards, explicit/default/empty progress, standard/Cloud Kafka, and live/replay/image paths were compared. Cross-type FROM, source-identity resets, default synthesis, failure atomicity, and replay membership checks are already covered by existing threads.
  • Test coverage and results: The changed tests cover parser constraints, mocked target validation, live target assignment, target-only replay, old-log decoding, and one ordered Kafka target-only regression. They do not cover target plus legacy partial_columns or Cloud MetaService progress plus failover, directly masking the two comments. The changed .out matches the ordered regression queries. No build or test was run in this review because the governing review prompt forbids builds/tests.
  • Observability and error handling: Existing Routine Load and replay logs are sufficient for this administrative path; the unchecked null/wrong-job path and the missing durable progress are correctness defects rather than missing diagnostics.
  • Data correctness and writes: No BE row-write implementation changes, but Routine Load offsets decide which records reach the new target. The Cloud deletion can skip or reconsume data after failover.
  • FE/BE propagation: No new FE-to-BE protocol variable is introduced; task planning already resolves the job's current table ID and existing source fields.
  • Performance: Target planning is ALTER-time control-plane work, not a hot loop. No distinct CPU, memory, or hot-path regression was found; existing metadata-lock I/O/journal concerns were deduplicated.
  • Other issues and user focus: No additional user-provided focus was present. Every suspicious point has a main-agent status, and the final 15-file/unresolved-risk sweep found no third distinct issue.

Review convergence: Round 1 found these two candidates. After main verification and live duplicate refresh, both normal full-review lanes and the separate risk lane repeated a complete Round 2 review and each returned NO_NEW_VALUABLE_FINDINGS for this exact head, 33-comment context, bodies, severities, and anchors. Validation was static only as required.

### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#64878

Problem Summary: The target-table ALTER path still accepted Kinesis jobs and persisted target-table IDs through Kinesis mutation and replay, which expanded the feature beyond its intended Kafka-only scope and exposed unrelated Kinesis source-transition issues to this PR. Reject SET TARGET TABLE for non-Kafka jobs, remove the Kinesis target-table mutation and replay changes, and replace the Kinesis positive test with a Kafka-only rejection test. Existing Kinesis property-only ALTER behavior remains unchanged.

### Release note

ALTER ROUTINE LOAD SET TARGET TABLE supports Kafka Routine Load jobs only.

### Check List (For Author)

- Test: Unit Test
    - ./run-fe-ut.sh --run org.apache.doris.nereids.trees.plans.commands.AlterRoutineLoadCommandTest,org.apache.doris.load.routineload.KafkaRoutineLoadJobTest,org.apache.doris.load.routineload.KinesisRoutineLoadJobTest
- Behavior changed: Yes. Kinesis jobs now reject SET TARGET TABLE while existing property-only ALTER remains supported.
- Does this need documentation: Yes. apache/doris-website#3988
@0AyanamiRei

0AyanamiRei commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 96.67% (58/60) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29643 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 963ed3e911beec89ae9b8bd198a56d154568a8a4, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17769	4216	4262	4216
q2	2058	333	198	198
q3	10253	1445	840	840
q4	4680	481	358	358
q5	7517	849	571	571
q6	187	170	141	141
q7	766	820	604	604
q8	9416	1556	1603	1556
q9	5996	4393	4344	4344
q10	6852	1706	1477	1477
q11	516	368	325	325
q12	743	593	467	467
q13	18086	3274	2778	2778
q14	262	258	242	242
q15	q16	784	778	707	707
q17	986	1060	982	982
q18	7193	5772	5556	5556
q19	1155	1284	1104	1104
q20	808	645	573	573
q21	5643	2615	2311	2311
q22	429	362	293	293
Total cold run time: 102099 ms
Total hot run time: 29643 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4407	4400	4427	4400
q2	297	325	211	211
q3	4589	4936	4419	4419
q4	2085	2167	1362	1362
q5	4418	4307	4340	4307
q6	232	182	133	133
q7	1773	1693	1505	1505
q8	2314	2079	2012	2012
q9	7223	7278	7209	7209
q10	4628	4600	4206	4206
q11	541	436	396	396
q12	755	750	540	540
q13	2966	3329	2753	2753
q14	284	291	263	263
q15	q16	685	717	615	615
q17	1305	1287	1277	1277
q18	7326	6853	6821	6821
q19	1124	1088	1084	1084
q20	2224	2224	1960	1960
q21	5285	4656	4465	4465
q22	522	459	418	418
Total cold run time: 54983 ms
Total hot run time: 50356 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 180734 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 963ed3e911beec89ae9b8bd198a56d154568a8a4, data reload: false

query5	4329	658	499	499
query6	466	230	212	212
query7	4834	644	327	327
query8	336	196	175	175
query9	8789	4153	4150	4150
query10	474	373	312	312
query11	6084	2399	2210	2210
query12	160	105	104	104
query13	1347	635	441	441
query14	6899	5391	5167	5167
query14_1	4508	4465	4429	4429
query15	216	217	188	188
query16	1042	507	483	483
query17	1114	727	560	560
query18	2716	505	345	345
query19	201	182	161	161
query20	116	108	109	108
query21	240	161	136	136
query22	13660	13549	13367	13367
query23	17626	16674	16148	16148
query23_1	16353	16260	16325	16260
query24	7435	1829	1309	1309
query24_1	1332	1297	1314	1297
query25	540	447	392	392
query26	1344	383	215	215
query27	2537	614	386	386
query28	4419	2028	1978	1978
query29	1095	640	481	481
query30	356	266	246	246
query31	1140	1103	998	998
query32	109	61	61	61
query33	522	334	263	263
query34	1203	1163	654	654
query35	844	804	696	696
query36	1212	1173	1041	1041
query37	157	113	95	95
query38	1934	1768	1699	1699
query39	891	898	862	862
query39_1	846	839	844	839
query40	259	186	155	155
query41	72	68	70	68
query42	96	94	92	92
query43	350	347	299	299
query44	1475	793	790	790
query45	198	184	175	175
query46	1134	1215	747	747
query47	2102	2105	1993	1993
query48	399	403	308	308
query49	609	435	336	336
query50	1049	443	353	353
query51	10652	10714	10668	10668
query52	88	90	79	79
query53	271	295	201	201
query54	292	244	239	239
query55	83	74	66	66
query56	311	342	314	314
query57	1289	1274	1205	1205
query58	301	286	262	262
query59	1659	1715	1501	1501
query60	325	293	306	293
query61	180	170	171	170
query62	560	516	447	447
query63	252	217	226	217
query64	2921	1016	847	847
query65	4946	4758	4773	4758
query66	1816	511	379	379
query67	29293	29649	29453	29453
query68	3171	1632	968	968
query69	424	310	277	277
query70	1047	999	972	972
query71	391	364	324	324
query72	3073	2729	2390	2390
query73	869	794	451	451
query74	5080	4967	4787	4787
query75	2589	2543	2165	2165
query76	2306	1224	815	815
query77	353	379	277	277
query78	12497	12099	11581	11581
query79	1409	1195	742	742
query80	1205	555	473	473
query81	534	348	296	296
query82	557	157	128	128
query83	410	337	303	303
query84	289	165	134	134
query85	986	624	510	510
query86	401	309	265	265
query87	1874	1887	1792	1792
query88	3769	2825	2794	2794
query89	436	387	325	325
query90	1785	205	204	204
query91	203	194	167	167
query92	67	59	61	59
query93	1587	1528	1047	1047
query94	652	354	319	319
query95	801	539	558	539
query96	1050	830	348	348
query97	2629	2641	2489	2489
query98	230	209	201	201
query99	1105	1124	998	998
Total cold run time: 266586 ms
Total hot run time: 180734 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 25.12 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 963ed3e911beec89ae9b8bd198a56d154568a8a4, data reload: false

query1	0.01	0.01	0.01
query2	0.10	0.05	0.04
query3	0.26	0.14	0.14
query4	1.61	0.16	0.14
query5	0.25	0.22	0.22
query6	1.25	1.10	1.08
query7	0.04	0.01	0.01
query8	0.05	0.04	0.03
query9	0.37	0.33	0.35
query10	0.54	0.56	0.54
query11	0.20	0.13	0.14
query12	0.18	0.14	0.15
query13	0.48	0.47	0.48
query14	1.01	1.01	1.00
query15	0.63	0.60	0.59
query16	0.31	0.33	0.32
query17	1.12	1.13	1.10
query18	0.24	0.22	0.22
query19	2.07	1.93	1.91
query20	0.02	0.02	0.01
query21	15.44	0.22	0.15
query22	4.84	0.06	0.05
query23	16.10	0.32	0.12
query24	2.99	0.44	0.32
query25	0.11	0.05	0.04
query26	0.73	0.21	0.16
query27	0.05	0.04	0.03
query28	3.50	0.94	0.52
query29	12.48	4.12	3.32
query30	0.27	0.15	0.15
query31	2.77	0.59	0.31
query32	3.22	0.59	0.49
query33	3.17	3.27	3.20
query34	15.77	4.21	3.51
query35	3.55	3.56	3.52
query36	0.58	0.45	0.42
query37	0.10	0.07	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.18	0.17	0.17
query41	0.08	0.03	0.03
query42	0.04	0.03	0.02
query43	0.04	0.04	0.03
Total cold run time: 96.84 s
Total hot run time: 25.12 s

@sollhui

sollhui commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes.

I found one new P1 mixed-version persistence issue (inline): an older electable FE can successfully replay the known ALTER ROUTINE LOAD opcode while dropping the new target-table field, then resume ingestion into the old table after failover. I did not duplicate the existing threads covering effective-property planning, validation/commit races, Kafka/Cloud progress atomicity, same-version replay/image drift, explicit source-type loss, or mutable-table authorization/existence races.

Critical checkpoint conclusions:

  • Goal and scope: the focused 13-file patch implements the Kafka target-switch syntax, live happy path, and same-version target-only replay, but the feature is not end-to-end safe until the mixed-version journal gap and the already-raised correctness blockers are resolved.
  • Concurrency: the live assignment is serialized by the job write lock and the PAUSED task/commit lifecycle did not expose an additional leak. Existing threads already cover the validation-to-commit generation gaps and unsynchronized mutable-table consumers.
  • Lifecycle, persistence, transactions, and data writes: old-log -> new-reader compatibility and same-version target-only replay are sound. New-log -> old-reader replay is not: failover can route future Kafka transactions and plans to the old target. Existing threads separately cover follower-local progress, checkpoint reconstruction, and pre-journal Cloud side effects.
  • Compatibility and parallel paths: Kafka-only target switching is enforced and Kinesis property-only behavior remains parallel by design. No configuration or FE-BE protocol field is added; the reused FE journal record is the blocking compatibility boundary.
  • Conditions, errors, observability, and performance: target validation performs one planner construction per ALTER and adds no recurring hot-path work. I found no separate new observability or error-propagation issue beyond the existing review threads.
  • Tests and results: the changed unit/regression tests cover parsing, target constraints, live target-only/combined mutation, planner unlock, same-version replay, old-log deserialization, and deterministic future-record routing. They do not cover mixed-version replay/failover. Live CI shows compile, FE UT, P0, non-concurrent, external, Cloud, vault, and performance checks passing; check_coverage_fe is failing. No local build or test was run because this review workflow explicitly forbids builds.
  • Documentation and focus: the linked documentation PR exists and describes the Kafka-only scope. No additional user-provided review focus was supplied.

Overall, the PR is not ready to merge while these data-routing and persistence issues remain.

@SerializedName(value = "dataSourceProperties")
private AbstractDataSourceProperties dataSourceProperties;
@SerializedName(value = "targetTableId")
private long targetTableId;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Prevent old FE followers from silently dropping the target switch. This field is added to the existing OP_ALTER_ROUTINE_LOAD_JOB JSON record, so an older electable FE recognizes the opcode and replays the known empty job/source delta, while Gson ignores the unknown targetTableId and the old Kafka replay path never changes tableId. During a rolling upgrade, if the old master fails after one upgraded follower rejoins, that new binary can become master while another follower still runs the old binary; after it switches a paused job from A to B, failover to the old follower makes beginTxn and task planning use A's ID and sends the continued stream back to A. The missing-field test covers only old-log -> new-reader compatibility, not this new-writer -> old-reader direction. Gate this ALTER until every electable FE advertises support, or use a versioned record/protocol that an old FE cannot silently accept, and add a mixed-version replay/failover test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants